/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entities;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import vo.VOTestcase;

/**
 *
 * @author sbaldrich
 */
@Entity
@Table(name = "testcase")
@NamedQueries(
{
    @NamedQuery(name = "Testcase.findAll", query = "SELECT t FROM Testcase t"),
    @NamedQuery(name = "Testcase.findByIdTestCase", query = "SELECT t FROM Testcase t WHERE t.idTestCase = :idTestCase")
})
public class Testcase implements Serializable
{

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idTestCase")
    private Integer idTestCase;
    @Basic(optional = false)
    @Lob
    @Column(name = "input")
    private String input;
    @Basic(optional = false)
    @Lob
    @Column(name = "output")
    private String output;
    @JoinColumn(name = "idProblem", referencedColumnName = "idProblem")
    @ManyToOne(optional = false)
    private Problem problem;

    public Testcase()
    {
    }

    public Testcase(Integer idTestCase)
    {
        this.idTestCase = idTestCase;
    }

    public Testcase(Integer idTestCase, String input, String output)
    {
        this.idTestCase = idTestCase;
        this.input = input;
        this.output = output;
    }

    public Testcase(VOTestcase vo)
    {
        this.setIdTestCase(vo.getIdTestCase());
        this.setInput(vo.getInput());
        this.setOutput(vo.getOutput());
    }

    public Integer getIdTestCase()
    {
        return idTestCase;
    }

    public void setIdTestCase(Integer idTestCase)
    {
        this.idTestCase = idTestCase;
    }

    public String getInput()
    {
        return input;
    }

    public void setInput(String input)
    {
        this.input = input;
    }

    public String getOutput()
    {
        return output;
    }

    public void setOutput(String output)
    {
        this.output = output;
    }

    public Problem getProblem()
    {
        return problem;
    }

    public void setProblem(Problem problem)
    {
        this.problem = problem;
    }

    @Override
    public int hashCode()
    {
        int hash = 0;
        hash += (idTestCase != null ? idTestCase.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object)
    {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Testcase))
        {
            return false;
        }
        Testcase other = (Testcase) object;
        if ((this.idTestCase == null && other.idTestCase != null) || (this.idTestCase != null && !this.idTestCase.equals(other.idTestCase)))
        {
            return false;
        }
        return true;
    }

    @Override
    public String toString()
    {
        return "entities.Testcase[idTestCase=" + idTestCase + "]";
    }

    public VOTestcase getVO()
    {
        return new VOTestcase(this);
    }
}
